import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:mandoby/core/utils/app_colors.dart';
import 'package:mandoby/features/Choosing_college/presentation/pages/choose_college_screen.dart';
import 'package:mandoby/features/home/presentation/pages/home_screen.dart';
import 'package:mandoby/features/my_requests/presentation/pages/my_requests_screen.dart';
import 'package:mandoby/features/nationally/presentation/pages/nationally_screen.dart';
import 'package:mandoby/features/profile/presentation/pages/profile_screen.dart';
import 'package:nb_utils/nb_utils.dart';

import '../../features/saerch/presentation/pages/saerch_screen.dart';
import '../app_export.dart';
import '../models/nav_bar_model.dart';

class CustomBottomBar extends StatefulWidget {
  const CustomBottomBar(
      {super.key, this.onChanged, required this.selectedIndex});

  final Function()? onChanged;
  final int selectedIndex;

  @override
  CustomBottomBarState createState() => CustomBottomBarState();
}

class CustomBottomBarState extends State<CustomBottomBar> {
  List<BottomMenuModel> bottomMenuList = [
    BottomMenuModel(
      icon: AppAssets.imgNav24x24,
      activeIcon: AppAssets.imgNav24x24,
      title: "الرئيسية",
    ),
    BottomMenuModel(
      icon: AppAssets.imgNavBlue90024x24,
      activeIcon: AppAssets.imgNavBlue90024x24,
      title: "بحث",
    ),
    BottomMenuModel(
      icon: AppAssets.imgNavBlue900,
      activeIcon: AppAssets.imgNavBlue900,
      title: "طلباتي",
    ),
    BottomMenuModel(
      icon: AppAssets.imgNav,
      activeIcon: AppAssets.imgNav,
      title: "ملفي",
    ),



  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 84.h,
      decoration: BoxDecoration(
        color: AppColors.whiteA700,
        borderRadius: BorderRadius.vertical(
          top: Radius.circular(7.w),
        ),
      ),
      child: BottomNavigationBar(
        backgroundColor: Colors.transparent,
        showSelectedLabels: false,
        showUnselectedLabels: false,
        selectedFontSize: 0,
        elevation: 0,
        currentIndex: widget.selectedIndex,
        type: BottomNavigationBarType.fixed,
        items: List.generate(bottomMenuList.length, (index) {
          return BottomNavigationBarItem(
            icon: Column(
              mainAxisSize: MainAxisSize.min,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                CustomImageView(
                  imagePath: bottomMenuList[index].icon,
                  height: 22.h,
                  width: 20.w,
                  color: AppColors.black600,
                ),
                Padding(
                  padding: EdgeInsets.only(top: 7.h),
                  child: Text(
                    bottomMenuList[index].title ?? "",
                    style: CustomTextStyles.font17gray600,
                  ),
                )
              ],
            ),
            activeIcon: Column(
              mainAxisSize: MainAxisSize.min,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                CustomImageView(
                  imagePath: bottomMenuList[index].activeIcon,
                  height: 22.h,
                  width: 20.w,
                  color: AppColors.primary,
                ),
                Padding(
                  padding: EdgeInsets.only(top: 11.h),
                  child: Text(
                    bottomMenuList[index].title ?? "",
                    style: CustomTextStyles.font17gray600
                        .copyWith(color: AppColors.primary),
                  ),
                )
              ],
            ),
            label: '',
          );
        }),
        onTap: (index) {
          if (index == 3) {
            ProfileScreen().launch(context, isNewTask: true,duration: 50.ms);
          } else if (index == 1) {
            SearchScreen().launch(context, isNewTask: true,duration: 50.ms);
          } else if (index == 2) {
            MyRequestsScreen().launch(context, isNewTask: true,duration: 50.ms);
          } else {
            HomeScreen().launch(context, isNewTask: true,duration: 50.ms);
          }
        },
      ),
    );
  }
}
